package solution;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-01-21
 * Time: 15:20
 */

//https://leetcode.cn/problems/check-permutation-lcci/submissions/396566919/
class Solution1 {
    public boolean CheckPermutation(String s1, String s2) {
        int ls1 = s1.length();
        int ls2 = s2.length();
        if (ls1 != ls2) {
            return false;
        }
        int[] counts = new int[26];
        for (int i = 0; i < ls1; i++) {
            counts[s1.charAt(i) - 'a']++;
            counts[s2.charAt(i) - 'a']--;
        }
        for (int i : counts) {
            if (i != 0) {
                return false;
            }
        }
        return true;
    }
}
